import 'dart:ui';

import 'package:flutter/material.dart';
import 'res/listData.dart';


class GridViewbuilder extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      
        appBar: AppBar(
          title: Text("有点f麻烦"),
        ),
        body: HomeContent(),
    );
  }
}

class HomeContent extends StatelessWidget {
  Widget setData(context, index) {
    return ListTile(
      leading: Image.network(mListData[index]["imageUrl"]),
      title: Text(mListData[index]["title"]),
      subtitle: Text(mListData[index]["author"]),
    );
  }

  // Widget setData() {
  //   GridTile();
  // }

  Widget getData(context, index) {
    return Container(
      child: Column(
        children: <Widget>[
          Image.network(mListData[index]["imageUrl"]),
          SizedBox(
            height: 10,
          ),
          Text(
            mListData[index]["title"],
            textAlign: TextAlign.center,
          )
        ],
      ),
      decoration: BoxDecoration(
          border: Border.all(color: Colors.yellow, width: 1),
          borderRadius: BorderRadius.all(Radius.circular(8))),
    );
  }

  @override
  Widget build(BuildContext context) {
    return GridView.builder(
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisSpacing: 10.0, mainAxisSpacing: 10.0, crossAxisCount: 2),
      // childAspectRatio: 0.7,
      itemCount: mListData.length,
      itemBuilder: this.getData,
    );
  }
}
